package com.affablebean.model.repository;

import java.sql.SQLException;
import java.util.List;

import com.affablebean.model.bll.AbstractBLL;
import com.affablebean.model.entity.GenericEntity;

public abstract class AbstractRepository<E extends GenericEntity> {

	private final AbstractBLL<E> abstractBLL;

	public AbstractRepository(AbstractBLL<E> abstractBLL) {
		this.abstractBLL = abstractBLL;
	}

	public boolean add(E entity) throws SQLException {
		return abstractBLL.insertEntity(entity);
	}

	public boolean update(E entity) throws SQLException {
		return abstractBLL.updateEntity(entity);
	}

	public boolean remove(E entity) throws SQLException {
		return abstractBLL.deleteEntity(entity);
	}

	public List<E> getAll() throws SQLException {
		return abstractBLL.getAll();
	}

	public E findById(int id) throws SQLException {
		return abstractBLL.findById(id);
	}

	public int getCount() throws SQLException {
		return abstractBLL.getCount();
	}

}
